from django.db import models

#用户类
class Users(models.Model):
    username = models.CharField(max_length=50)			#用户名
    pwd = models.CharField(max_length=80)				#密码
    gender = models.IntegerField(default=1)				#性别
    address = models.CharField(max_length=255)			#收货地址
    code = models.CharField(max_length=6)				#邮编
    phone = models.CharField(max_length=16)				#联系电话
    head_img = models.CharField(max_length=50)			#用户头像
    state = models.IntegerField(default=1)				#用户状态 (0管理员,1普通用户,2禁用)
    addtime = models.DateTimeField(auto_now_add=True)	#用户添加时间

#商品类型类
class Types(models.Model):
    name = models.CharField(max_length=50)	#种类名称
    pid = models.IntegerField()				#从属父类id
    path = models.CharField(max_length=150)	#从属关系标记

#商品类
class Goods(models.Model):
    typeid = models.IntegerField()                      #商品类型id
    title = models.CharField(max_length=255)            #商品名称
    company = models.CharField(max_length=50)           #商品厂家
    desc = models.TextField()                           #商品描述
    price = models.FloatField()                         #商品单价
    photo_url = models.CharField(max_length=50)         #商品图片url
    state = models.IntegerField()                       #商品状态(1新添加,2在售,3下架)
    store = models.IntegerField()                       #商品库存
    num = models.IntegerField(null=True)                #商品被购买次数
    clicknum = models.IntegerField(null=True)           #商品被点击次数
    addtime = models.DateTimeField(auto_now_add=True)   #商品添加时间

#订单类
class Orders(models.Model):
    uid = models.IntegerField()                         #订单所有者id
    linkman = models.CharField(max_length=50)           #收货人姓名
    address = models.CharField(max_length=50)           #收货地址
    code = models.IntegerField()                        #邮编
    phone = models.CharField(max_length=11)             #联系人电话
    addtime = models.DateTimeField(auto_now_add=True)   #添加订单时间
    total = models.FloatField()                         #订单总价
    status = models.IntegerField()                      #订单状态 (0未支付 1已发货 2未收货 3已收货 4已取消)

#订单商品类
class Items(models.Model):
    orderid = models.IntegerField()             #商品所属订单id
    goodsid = models.IntegerField()             #商品id
    title = models.CharField(max_length=50)     #商品名称
    price = models.FloatField()                 #商品单价
    num = models.IntegerField()                 #购买数量
    goodspic = models.CharField(max_length=50)  #商品图片  

